﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Module.Core.DAO;
using Module.Core.EntitiesInfo;
using Module.Common.Models;

namespace Module.Core.BusinessLogic
{
    public class LogChuyenGoldBL
	{
		/// <summary>
		/// Saves a record to the Log_ChuyenGold table.
		/// </summary>
		public static int Insert(LogChuyenGoldInfo logChuyenGoldInfo)
		{
			try
			{
				 return new LogChuyenGoldDAO().Insert(logChuyenGoldInfo);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

        /// <summary>
        /// Saves a record to the Log_ChuyenGold table.
        /// </summary>
        public static int Insert1(LogChuyenGoldInfo logChuyenGoldInfo)
        {
            try
            {
                return new LogChuyenGoldDAO().Insert1(logChuyenGoldInfo);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

		/// <summary>
		/// Saves a record to the Log_ChuyenGold table.
		/// </summary>
        public static void Update(LogChuyenGoldInfo logChuyenGoldInfo)
		{
			try
			{
				new LogChuyenGoldDAO().Update(logChuyenGoldInfo);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Delete a record from the Log_ChuyenGold table.
		/// </summary>
        public static void Delete(int logId)
		{
			try
			{
				new LogChuyenGoldDAO().Delete(logId);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

		/// <summary>
		/// Selects a single record from the Log_ChuyenGold table.
		/// </summary>
        public static LogChuyenGoldInfo Select(int logId)
		{
			try
			{
				return new LogChuyenGoldDAO().Select(logId);
			}
			catch (Exception ex)
			{
				throw;
			}

		}


        /// <summary>
        /// Hiện thị lịch sử giao dịch
        /// </summary>
        /// 
       
        public static DataTable SelectTransactionHistory(string email)
        {
            try
            {
                return new LogChuyenGoldDAO().SelectTransactionHistory(email);
            }
            catch (Exception ex)
            {
                throw;
            }

        }
        //Phân trang lich sử giao dich

        public static DataSet ListTransactionHistory(string email, int currPage, int recodperPage, int pageSize,string link)
        {
            try
            {
                DataSet ds = new DataSet();

                ds = new LogChuyenGoldDAO().ListTransactionHistory(email, currPage, recodperPage, pageSize,link);
                if (ds != null)
                    return ds;
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }

        }


        
		/// <summary>
		/// Selects all records from the Log_ChuyenGold table.
		/// </summary>
        public static CHRTList<LogChuyenGoldInfo> SelectAll()
		{
			try
			{
				return new LogChuyenGoldDAO().SelectAll();
			}
			catch (Exception ex)
			{
				throw;
			}

		}

        public static int GetCount(int logId,DateTime createOnFrom, DateTime createOnTo)
        {
            try
            {
                return new LogChuyenGoldDAO().GetCount(logId, createOnFrom, createOnTo);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static DataTable SearchAll(DateTime createdOnFrom, DateTime createdOnTo, int from, int to)
        {
            try
            {
                return new LogChuyenGoldDAO().SearchAll(createdOnFrom, createdOnTo, from, to);
            }
            catch (Exception ex)
            {
                throw;
            }

        }


        #region Lấy thông tin của từng bản ghi
        public static LogChuyenGoldInfo SelectInfo(string  param,int flag)
        {
            try
            {
                return new LogChuyenGoldDAO().SelectInfo(param,flag);
            }
            catch (Exception)
            {
            }
            return null;

        }
        #endregion
        //public static CHRTList<LogChuyenGoldInfo> SelectAll(string param,int flag)
        //{
        //    try
        //    {
        //        return new LogChuyenGoldDAO().SelectAll(param,flag);
        //    }
        //    catch (Exception ex)
        //    {
        //        throw;
        //    }

        //}
        #region Update Status

        //Update lại trạng thái Status=2 -Chuyển gold ATM đang chờ xác nhận
        //Status=1 -Chuyển gold qua ATM đã xác nhận
        public static void UpdateStatus(int logId, int status)
        {
            try
            {
                new LogChuyenGoldDAO().UpdateStatus(logId, status);
            }
            catch (Exception ex)
            {
                throw;
            }

        }
        #endregion
        /// <summary>
        /// Lấy tổng số bản ghi
        /// </summary>        
        /// <param name="isTotalRow">=True lấy tổng sổ bản ghi</param>
        /// <returns></returns>
        public static int SelectCount(bool isTotalRow)
        {
            try
            {
                return new LogChuyenGoldDAO().SelectCount(isTotalRow);
            }
            catch (Exception ex)
            {
                throw;
            }

        }
        /// <summary>
        /// Lấy tổng số bản ghi
        /// </summary>
        /// <param name="beginRow">Bản ghi đầu tiên</param>
        /// <param name="endRow">Bản ghi kết thúc</param>
        /// <param name="orderByColumn">Điều kiện sắp xếp</param>       
        /// <returns></returns>
        public static DataTable Search1(int beginRow, int endRow, string orderByColumn)
        {
            try
            {
                return new LogChuyenGoldDAO().Search(beginRow, endRow, orderByColumn);
            }
            catch (Exception ex)
            {
                throw;
            }

        }


        public static DataSet ListLogChuyenGoldPage(int logId,  DateTime createOnFrom, DateTime createOnTo, int currPage, int recodperPage, int pageSize, int total, string link)
        {
            try
            {
                DataSet ds = new DataSet();

                ds = new LogChuyenGoldDAO().ListLogChuyenGoldPage(logId, createOnFrom, createOnTo, currPage, recodperPage, pageSize, total, link);
                if (ds != null)
                    return ds;
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }
            
        }

	}
}
